<template>
  <div id="app">
    <top-nav v-if="!$route.meta.hideNav"></top-nav>
    <tab-nav v-if="!$route.meta.hideNav"></tab-nav>
    <div v-if="!$route.meta.hideNav" :style="{ height: '130px' }"></div>
    <!-- <load-animate></load-animate>  -->

    <!-- keep-alive 缓存 -->
    <!-- <keep-alive> -->
    <router-view @play="play" :currentmusic="currentMusic">
      <slot></slot>
    </router-view>
    <!-- </keep-alive> -->

    <div v-if="!$route.meta.hideNav" :style="{ height: '60px' }"></div>

    <transition
      enter-active-class="animate__animated animate__backInLeft"
      leave-active-class="animate__animated animate__backInLeft"
    >
      <music-play
        v-if="currentMusic"
        :music="currentMusic"
        :playlist="playList"
        @play="play"
        @clear="clear"
      ></music-play>
    </transition>
    <!-- <router-link to="/">推荐音乐</router-link> -->
  </div>
</template>

<script>
import TabNav from "@/components/TabNav";
import TopNav from "@/components/TopNav";
import MusicPlay from "@/components/MusicPlay.vue";
import _ from "lodash";
import "animate.css";
// import LoadAnimate from '@/components/LoadAnimate.vue';
export default {
  data() {
    return {
      currentMusic: null,
      playList: [],
    };
  },
  created() {
    this.axios().then();
  },
  components: {
    TabNav,
    TopNav,
    MusicPlay,
    // LoadAnimate,
  },
  methods: {
    play(event) {
      // console.log("music===>", event);
      this.currentMusic = event;
      // console.log(this.currentMusic);
      this.playList.push(event);
      this.playList = _.uniq(this.playList);
    },
    clear(e) {
      console.log(e);
      if (this.currentMusic == e) {
        return;
      }
      this.playList = this.playList.filter((v) => {
        return v != e;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
#app {
  background-color: #fcfcfd;
  min-height: 100vh;
  overflow: hidden;
}
</style>